<template>
   <div>
   	  <router-view class="view"></router-view>
   	  <MyMenu></MyMenu>
   </div>
</template>

<script>

import MyMenu from './components/common/menu.vue'
export default {
  name: 'app',
  data () {
    return {
    }
  },
  mounted: function() {
  	_slefThis = this;
      this.getPartnerInfo();
    this.$router.push({
		path: '/agencyIndex'
	})
  },
    methods:{
      //实时获取用户信息
      getPartnerInfo(){
        var _self = this;
        var body = {};
        body.params = {}
        var url = this.utilHelper.apiUrl+'/api/getUserById';
          _self.$http.post(url, body).then((response) => {
              var data = response.body.resData;
              var result = data.result;
              if (result == "1") {
                  window.sessionStorage.setItem(_self.utilHelper.appAgency+"_userId", data.id);
                  window.sessionStorage.setItem(_self.utilHelper.appAgency+"_userName", data.accountName);
                  window.sessionStorage.setItem(_self.utilHelper.appAgency+"_phone", data.phone);
                  window.sessionStorage.setItem(_self.utilHelper.appAgency+"_isLogin", true);
                  window.sessionStorage.setItem(_self.utilHelper.appAgency+"_userRole", data.userRoleId);
                  window.sessionStorage.setItem(_self.utilHelper.appAgency+"_accountType",data.accountType);
              }
          });
      }
  },
  components:{
      MyMenu
  }
}
var _slefThis = this;
document.addEventListener( "plusready", onPlusReady, false );
function onPlusReady() {
        var webview = plus.webview.currentWebview();
        // 注册返回按键事件
        plus.key.addEventListener('backbutton', function() {
            webview.canBack(function(e){
            	if(scan){
            		scan.close();
            	}
            	if(_slefThis.$router){
            		if("/agencyIndex"== _slefThis.$route.fullPath){
            			plus.nativeUI.confirm( "确认退出?", function(e){
            				if(e.index==0){
            					plus.runtime.quit();
            				}
	                  	});
	            	}else{
	            		_slefThis.$router.back(-1);
	            	}	
            	}
            })

        }, false);
}
</script>
